<?php
/*
	Class to do connection with data base
*/
include_once("db_vars.php");
class dbm_Connection
{
	var $iConnectionID = 0;	
	var $sDataBase = "";			
	var $sHost = "";				
	var $sUser = "";				
	var $sPass = "";				
	var $sDbmErrLogPath = "";	
	//get values of te variables 
	function getVarConnection()
	{
		$db_vars = new dbm_vars();
		$this->sDataBase = $db_vars->getDataBase(); 			//data base name
		$this->sHost = $db_vars->getHost(); 					//host name
		$this->sUser = $db_vars->getUser(); 					//user
		$this->sPass = $db_vars->getPassword(); 				//password
		$this->sDbmErrLogPath = $db_vars->getErrorLogPath();	//error log
	}
	//do connection
	function dbConnection()
	{
		$this->getVarConnection();
		$this->iConnectionID = mysql_connect($this->sHost,$this->sUser,$this->sPass);
		if(!$this->iConnectionID)
		{
			return 0;		//connection failed
		}
		else
		{
			if(!@mysql_select_db($this->sDataBase, $this->iConnectionID))
			{
				return 0;		//access denied
			}
			else
			{
				return $this->iConnectionID;		//successful connection
			}
		}
	}
}
?>